package cn.lunatic.db;

import java.io.Serializable;

import cn.lunatic.data.DataMap;
import cn.lunatic.data.DataTable;
import cn.lunatic.data.SqlStatement;
import cn.lunatic.pub.Constant;

/**
 * @Description:
 * @author ganfeng
 * @date 2014-3-10 上午11:30:00
 */
public class Dao implements Serializable{

	private static final long serialVersionUID = 3052032904462534989L;
	
	public static int execInsertReturnKey(String sqlId , DataMap params){
		SqlStatement statement = SQLParseUtil.parseSQLBySqlID(sqlId, params, Constant.SQL_TYPE_UPDATE);
		SqlExecutor executor = new SqlExecutor();
		return executor.execInsertReturnKey(statement);
	}
	
	public static int executeUpdate(String sqlId , DataMap params){
		SqlStatement statement = SQLParseUtil.parseSQLBySqlID(sqlId, params, Constant.SQL_TYPE_UPDATE);
		SqlExecutor executor = new SqlExecutor();
		return executor.update(statement);
	}
	
	public static DataTable executeQuery(String sqlId , DataMap params){
		SqlStatement statement = SQLParseUtil.parseSQLBySqlID(sqlId, params, Constant.SQL_TYPE_QUERY);
		SqlExecutor executor = new SqlExecutor();
		return executor.query(statement);
	}

}
